<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author: LJQ <245369209@qq.com> 
// +----------------------------------------------------------------------

namespace app\inspection\model;
use app\common\model\Base;

/**
 * 巡检项目
 */
class Item extends Base{

	protected $name = "inspectionitem";
	protected $createTime = 'createTime';
	protected $updateTime = 'updateTime';

	
	public function getCycleList(){
		$cycleList = db('basicinfo')->where('sysCode',24)->column('subsystemName','subsystemNo');
		return $cycleList;
	}
	
	public function getImportanceList(){
		$importanceList = db('basicinfo')->where('sysCode',23)->column('subsystemName','subsystemNo');
		return $importanceList;
	}
	
	public function getCycleIdAttr($value,$data){
		$cycleList = $this->getCycleList();
		if($data['cycleId']){
			return $cycleList[$data['cycleId']];
		}
		return null;
	}
	
	public function getImportanceAttr($value,$data){
		$importanceList = $this->getImportanceList();
		if($data['importance']){
			return $importanceList[$data['importance']];
		}
		return null;
	}
	public function enterprise(){

		return $this->hasOne('app\basic\model\Enterprise','id','enterpriseId');
	}
	
	public function record (){
		return $this->hasOne('Record','id','lastRecord');
	}
	
}